#include<cstdio>
using namespace std;
int n,l,r,mx=0;
int max(int a,int b)
{
	if(a>b) return a;
	else return b;
}
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	for(int i=l;i<=r;i++)
	{
		mx=max(mx,i%n);
	}
	printf("%d",mx);
} 
